using System;
using System.Linq;
using System.Threading.Tasks;
using CR.Domain.DbContext;
using CR.Domain.Entities;
using Microsoft.EntityFrameworkCore;

namespace CR.Infrastructure.Repositories
{
    /// <summary>
    /// 养殖信息仓储实现类
    /// </summary>
    public class BreedingInfoRepository : BaseRepository<BreedingInfo>, IBreedingInfoRepository
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="context">数据库上下文</param>
        public BreedingInfoRepository(TraceabilityDbContext context) : base(context)
        {
        }

        /// <inheritdoc/>
        public async Task<BreedingInfo> GetByTraceabilityCodeAsync(string traceabilityCode)
        {
            return await _dbSet
                .FirstOrDefaultAsync(b => b.TraceabilityCode == traceabilityCode);
        }
    }
} 